package logic

import (
	"baidu-dev/models"
	"context"
	"errors"

	"baidu-dev/baidurpc/baidurpc"
	"baidu-dev/baidurpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type DelLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DelLogic {
	return &DelLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 删除
func (l *DelLogic) Del(in *baidurpc.DelRequest) (*baidurpc.DelResponse, error) {
	// todo: add your logic here and delete this line

	var user models.User

	if err := user.UserDel(models.DB, in.UserId); err != nil {
		return nil, errors.New("删除成功")
	}

	return &baidurpc.DelResponse{}, nil
}
